﻿@using Gx.Model.ViewModel;
@model LKSettlementPaymentDto
@{
    ViewBag.Title = "编辑结算收款单";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
<script src="~/Js/Global.js"></script>
<script type="text/javascript">
    $(function () {
        InitPayTypeCombobox();
        InitBankCombobox();
        InitCustomer();
        $('#CustomerId').combogrid('setValue', { Id: '@Model.SettlementPayment.CustomerId', CustomerName: '@Model.SettlementPayment.CustomerName' });

        addCostTr();
    });

    function formatter_BeginTime(value, rowData, rowIndex) {
        return formatdate(rowData.BeginTime);
    }
    function formatter_EndTime(value, rowData, rowIndex) {
        return formatdate(rowData.EndTime);
    }
    var detaildom = new Array();
    function InitPayTypeCombobox(domId) {
        if (domId == undefined) {
            domId = "";
        }
        $('#PaymentTypeId' + domId).combobox({
            url: "/LkGlobal/GetPayTypeList",
            valueField: 'Value',
            textField: 'Description',
            onSelect: function (rec) {
                //$('#StoreType').combobox("setValue", rec.Value);
            }
        })
    }

    function InitBankCombobox(domId) {
        if (domId == undefined) {
            domId = "";
        }
        $('#Bank' + domId).combobox({
            url: "/LkGlobal/GetBanksList",
            valueField: 'Value',
            textField: 'Description',
            onSelect: function (rec) {
                //$('#StoreType').combobox("setValue", rec.Value);
            }
        })
    }

    function doSearch() {
        $('#dg').datagrid('load', {
            CustomerId: $("#CustomerId").combobox('getValue'),
            BeginTime: $("#BeginTime").datebox('getValue'),
            EndTime: $("#EndTime").datebox('getValue'),
            GoodsNo: $("#GoodsNo").val()
        });
    }

    function addDom() {
        var customerId = $("#CustomerId").combobox('getValue');
        if (customerId == "") {
            Helper.Show("请选择客户");
            return;
        }
        var currentDate = new Date();
        $("#BeginTime").datebox('setValue', '');
        $("#EndTime").datebox('setValue', formatdate(currentDate));
        $("#GoodsNo").textbox('setValue', '')
        $('#dlg').dialog('open').dialog('setTitle', '引入费用明细');
        $('#dg').datagrid('load', {
            CustomerId: customerId,
            BeginTime: $("#BeginTime").datebox('getValue'),
            EndTime: $("#EndTime").datebox('getValue'),
            GoodsNo: $("#GoodsNo").val()
        });
        initDom();
    }

    function initDom() {
        detaildom.length = 0;
        $("input[type='hidden'][id^='DetailDomId']").each(function () {
            var d = $(this).val();
            if ($.inArray(d, detaildom) === -1) {
                detaildom.push(d);
            }
        });

    }

    var bcArr = new Array();
    function initBcht() {
        $('span[id*="GoodsNo"]').each(function () {
            //获取triggerControl的id的最后一个字符
            var id = $(this).attr("id");
            var lastChar = id.substr(id.length - 1, 1);
            var begintime = $("#BeginTime" + lastChar).text();
            var endtime = $("#EndTime" + lastChar).text();
            var goodsno = $(this).text();
            var costdetail = { BeginTime: begintime, EndTime: endtime, GoodsNo: goodsno };
            var exists = $.grep(bcArr, function (e) {
                return e.BeginTime === costdetail.BeginTime && e.EndTime === costdetail.EndTime && e.GoodsNo === costdetail.GoodsNo;
            });
            if (exists.length == 0) {
                bcArr.push(costdetail);
            }
            //var bc = $(this).text();
            //if ($.inArray(bc, bcArr) === -1) {
            //    bcArr.push(bc);
            //}

        });
    }

    function addPayDetail() {
        $('#dlg2').dialog('open').dialog('setTitle', '付款明细')
    }
    function savePayDetail() {
        var cashAndBank = $("#CashAndBank").numberbox('getValue') * 1;
        var prePay = $("#PrePay").numberbox('getValue') * 1;
        var cashDiscount = $("#CashDiscount").numberbox('getValue') * 1;

        var Amount = $("#Amount").numberbox('getValue') * 1;

        if (cashAndBank + prePay + cashDiscount != Amount) {
            Helper.Show("实收金额与冷藏金额不一致");
            return;
        }

        $("#ActualAmount").numberbox('setValue', cashAndBank + prePay + cashDiscount);
        //var zhekou = "现金折扣:" + cashDiscount + "元";
        $("#zhekouspan").numberbox('setValue', cashDiscount);
        $('#dlg2').dialog('close');
    }

    function selectEntryCostDetail() {

        domId = $("#DomNum").val();
        var rows = $('#dg').datagrid('getSelections');
        if (rows == null) {
            Helper.Show("请选择明细");
            return;
        }
        var amount = $("#Amount").numberbox('getValue') * 1;
        rows.forEach(function (value, index) {
            initBcht();
            if (value != null) {
                //var customerId = $("#CustomerId").combobox('getValue');
                //$.ajax({
                //    url: '/Finance/_AddLKSettlementPaymentBcDetail',
                //    type: "post",
                //    async: false,
                //    data: { DomId: domId, GoodsNo: value.GoodsNo, CustomerId: customerId },
                //    success: function (html) {
                //        if (html.indexOf('td') !== -1) {
                //            var ck = true;
                //            bcArr.forEach(function (bcvalue, index) {
                //                if (html.indexOf(bcvalue.GoodsNo) > -1) {
                //                    ck = false;
                //                    return false;
                //                }
                //            });
                //            if (ck == true) {
                //                $.messager.progress('close');
                //                $("#detailgird tbody").append(html);
                //                $.parser.parse($("#" + domId));
                //                amount += ($("#TotalAmount" + domId).text() * 1);

                //            }
                //            domId = Number(domId) + 1;
                //        }
                //    }
                //});

                $.ajax({
                    url: '/Finance/_AddLKSettlementPaymentDetail',
                    type: "post",
                    async: false,
                    data: { domId: domId },
                    success: function (html) {
                        var ck = true;
                        bcArr.forEach(function (bcvalue, index) {
                            if (formatdate(value.BeginTime) === bcvalue.BeginTime && formatdate(value.EndTime) === bcvalue.EndTime && value.GoodsNo === bcvalue.GoodsNo) {
                                ck = false;
                                return false;
                            }
                        });

                        if (ck == true) {
                            $.messager.progress('close');
                            $("#detailgird tbody").append(html);
                            $.parser.parse($("#" + domId));
                            initOutDetail(domId, value);

                            amount += ($("#TotalAmount" + domId).text() * 1);
                        }
                        $("#DomNum").val(Number(domId) + 1);


                        //if ($.inArray(value.GoodsNo, bcArr) === -1) {
                        //    $.messager.progress('close');
                        //    $("#detailgird tbody").append(html);
                        //    $.parser.parse($("#" + domId));
                        //    initOutDetail(domId, value);

                        //    amount += ($("#TotalAmount" + domId).text() * 1);
                        //}
                        //$("#DomNum").val(Number(domId) + 1);
                    }
                });
                //amount += (value.TotalAmount*1)
            }
        });


        addCostTr();

        $("#Amount").numberbox('setValue', $('#TotalAmounthj').text() * 1);

        $('#dlg').dialog('close');
    }
    function initOutDetail(id, detail) {
        $("#BeginTime" + id).text(formatdate(detail.BeginTime));
        //$("#BeginTime" + id).val(detail.BeginTime);//datebox('setValue', detail.BeginTime);
        $("#EndTime" + id).text(formatdate(detail.EndTime));
        $("#Days" + id).text(detail.Days);
        $("#GoodsNo" + id).text(detail.GoodsNo);
        $("#GoodsId" + id).val(detail.GoodsId);
        $("#GoodsName" + id).text(detail.GoodsName);
        $("#GoodsSpecId" + id).val(detail.GoodsSpecId);
        $("#GoodsSpecName" + id).text(detail.GoodsSpecName);
        $("#CostType" + id).text(detail.CostType);
        $("#ContainerNumber" + id).text(detail.ContainerNumber);

        $("#Weight" + id).text(detail.Weight);
        $("#Number" + id).text(detail.Number);

        $("#TonWeight" + id).text(detail.TonWeight);
        $("#Area" + id).text(detail.Area);
        $("#PlateNumber" + id).text(detail.PlateNumber);
        $("#ColdUnitPrice" + id).text(detail.ColdUnitPrice);
        $("#ColdCost" + id).text(detail.ColdCost);
        $("#Chuzhi" + id).text(detail.Chuzhi);
        $("#Zhuangxie" + id).text(detail.Zhuangxie);
        $("#Jiaban" + id).text(detail.Jiaban);
        $("#Fenjian" + id).text(detail.Fenjian);
        $("#Guobang" + id).text(detail.Guobang);
        $("#Peisong" + id).text(detail.Peisong);
        $("#Qita" + id).text(detail.Qita);
        $("#TotalAmount" + id).text(detail.TotalAmount);

    }

    function addCostTr() {
        $("#hjtr").remove();
        //$.parser.parse($("#hjtr"));
        $.ajax({
            url: '/Finance/_CostTotal',
            type: "post",
            async: false,
            success: function (html) {
                $.messager.progress('close');

                $('#detailgird tbody').append(html);
                //$.parser.parse($("#" + domId));
                initCostHj();
            }
        });
    }
    function initCostHj() {
        $('#ColdCosthj').text(getTotalAmount('ColdCost'));
        $('#Chuzhihj').text(getTotalAmount('Chuzhi'));
        $('#Zhuangxiehj').text(getTotalAmount('Zhuangxie'));
        $('#Jiabanhj').text(getTotalAmount('Jiaban'));
        $('#Fenjianhj').text(getTotalAmount('Fenjian'));
        $('#Guobanghj').text(getTotalAmount('Guobang'));
        $('#Peisonghj').text(getTotalAmount('Peisong'));
        $('#Qitahj').text(getTotalAmount('Qita'));
        $('#TotalAmounthj').text(getTotalAmount('TotalAmount'));
    }

    function getTotalAmount(id) {
        var totalamount = 0;
        id = 'span[id*="' + id + '"]';
        $(id).each(function () {
            var amount = $(this).text() * 1;
            totalamount += amount;
        });
        return totalamount.toFixed(2);
    }


    function editLKSettlementPayment() {
        var validate = $("#fm").form("validate")
        if (!validate) {
            return;
        }
        var data = {
            "Id": $("#Id").val(),
            "BillNo": $("#BillNo").textbox('getValue'),
            "PaymentTime": $("#PaymentTime").datebox('getValue'),
            "CustomerId": $("#CustomerId").combobox('getValue'),//$("#hidCustomerId").val(),
            "CustomerNo": $("#CustomerId").combobox('getText'),
            "CustomerName": $("#CustomerName").textbox('getValue'),
            "PaymentTypeId": $("#PaymentTypeId").combobox('getValue'),
            "PaymentType": $("#PaymentTypeId").combobox('getText'),
            "Bank": $("#Bank").combobox('getText'),
            "PreAmount": $("#PreAmount").numberbox('getValue'),
            "Amount": $("#Amount").numberbox('getValue'),
            "ActualAmount": $("#ActualAmount").numberbox('getValue'),
            "Remark": $("#Remark").val(),
            "CashAndBank": $("#CashAndBank").numberbox('getValue'),
            "PrePay": $("#PrePay").numberbox('getValue'),
            "CashDiscount": $("#CashDiscount").numberbox('getValue')
        };

        if (data.PrePay * 1 > data.PreAmount * 1) {
            Helper.Show("预付款不能大于预收款余额");
            return;
        }

        if (data.PrePay * 1 + data.CashAndBank * 1 + data.CashDiscount * 1 != data.Amount * 1) {
            Helper.Show("实收金额与冷藏金额不一致");
            return;
        }


        initDom();
        var detailList = new Array();
        detaildom.forEach(function (value, index) {
            var i = value;
            var Id = $("#DetailId" + i).val();
            var SettlementId = $("#SettlementId" + i).val();
            var BeginTime = $("#BeginTime" + i).text();
            var EndTime = $("#EndTime" + i).text();
            var Days = $("#Days" + i).text();
            var GoodsNo = $("#GoodsNo" + i).text();
            var GoodsId = $("#GoodsId" + i).val();
            var GoodsName = $("#GoodsName" + i).text();
            var GoodsSpecId = $("#GoodsSpecId" + i).val();
            var GoodsSpecName = $("#GoodsSpecName" + i).text();
            var CostType = $("#CostType" + i).text();
            var ContainerNumber = $("#ContainerNumber" + i).text();
            var Weight = $("#Weight" + i).text();
            var number = $("#Number" + i).text();
            var TonWeight = $("#TonWeight" + i).text();
            var Area = $("#Area" + i).text();
            var PlateNumber = $("#PlateNumber" + i).text();
            var ColdUnitPrice = $("#ColdUnitPrice" + i).text();
            var ColdCost = $("#ColdCost" + i).text();
            var Chuzhi = $("#Chuzhi" + i).text();
            var Zhuangxie = $("#Zhuangxie" + i).text();
            var Jiaban = $("#Jiaban" + i).text();
            var Fenjian = $("#Fenjian" + i).text();
            var Guobang = $("#Guobang" + i).text();
            var Peisong = $("#Peisong" + i).text();
            var Qita = $("#Qita" + i).text();

            var detail = {
                "Id": Id,
                "SettlementId": SettlementId,
                "BeginTime": BeginTime,
                "EndTime": EndTime,
                "Days": Days,
                "GoodsNo": GoodsNo,
                "GoodsId": GoodsId,
                "GoodsName": GoodsName,
                "GoodsSpecId": GoodsSpecId,
                "GoodsSpecName": GoodsSpecName,
                "CostType": CostType,
                "ContainerNumber": ContainerNumber,
                "Weight": Weight,
                "Number": number,
                "TonWeight": TonWeight,
                "Area": Area,
                "PlateNumber": PlateNumber,
                "ColdUnitPrice": ColdUnitPrice,
                "ColdCost": ColdCost,
                "Chuzhi": Chuzhi,
                "Zhuangxie": Zhuangxie,
                "Jiaban": Jiaban,
                "Fenjian": Fenjian,
                "Guobang": Guobang,
                "Peisong": Peisong,
                "Qita": Qita,
            };
            detailList.push(detail);
        });
        var d = JSON.stringify({ SettlementPayment: data, Details: detailList });

        $.messager.progress({
            title: '请稍后',
            msg: '数据保存中...',
        });
        window.setTimeout(function () {
            $.ajax({
                url: '/Finance/EditLKSettlementPayment',
                type: "post",
                data: d,
                contentType: 'application/json; charset=utf-8',
                success: function (json) {
                    $.messager.progress('close');
                    Helper.Show(json.Msg);
                    if (json.Success) {
                        setTimeout(function () { window.location.href = "/Finance/LKSettlementPaymentList"; }, 2000);
                    }
                }
            });
        }, 2000);
    }

    function reviewLKSettlementPayment() {
        $.messager.confirm('提示信息', '您确认要复核吗?', function (r) {
            if (!r) { return false; }
            $.post("/Finance/CheckLKSettlementPayment", { id: $("#Id").val() }, function (json) {
                Helper.Show(json.Msg);
                if (json.Success) {
                    setTimeout(function () { window.location.href = "/Finance/LKSettlementPaymentList"; }, 2000);
                }
            });
        });
    }

    function print() {

        var printUrl = "/Finance/LKSettlementPaymentPrint?id=" + @Model.SettlementPayment.Id;
        window.open(printUrl, "_blank");
    }

</script>
<link href="~/Content/css/custome.css" rel="stylesheet" />
<div title="编辑结算收款单" style="width:auto; height:auto; padding-left:5px; font-size:14px;  ">
    <div class="ftitle">
        @if (!Model.SettlementPayment.IsReview)
        {
            <a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="editLKSettlementPayment()">保存</a>
            <a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="reviewLKSettlementPayment()">复核</a>
        }
        <a href="javascript:" class="easyui-linkbutton" data-options="iconCls:'icon-print'" onclick="print()">打印</a>
        <a href="/Finance/LKSettlementPaymentList" class="easyui-linkbutton" iconCls="icon-back" style="height:32px">返回</a>
    </div>
    <form id="fm" method="post" novalidate>
        <input type="hidden" id="Id" value="@Model.SettlementPayment.Id" />
        <div class="ftitle">基础信息</div>
        <div class="fitem1">
            <label>
                结算单编号:
            </label>
            <input class="easyui-textbox" value="@Model.SettlementPayment.BillNo" id="BillNo" name="BillNo" style="width: 173px; height: 30px;" readonly="readonly">
            <label>
                收款时间:
            </label>
            <input id="PaymentTime" name="PaymentTime" value="@Model.SettlementPayment.PaymentTime" class="easyui-datebox" style="width: 173px; height: 30px;" />
            <label>
                客户:
            </label>
            <input id="CustomerId" value="@Model.SettlementPayment.CustomerId" class="easyui-numberbox" data-options="prompt:'客户Id'" style="width: 173px; height: 30px;" />
            <label>
                客户名称:
            </label>
            <input class="easyui-textbox" id="CustomerName" name="CustomerName" value="@Model.SettlementPayment.CustomerName" style="width: 173px; height: 30px;" readonly="readonly">
        </div>
        <div class="fitem1">
            <label>
                付款方式
            </label>
            @{
                var paytype = Model.SettlementPayment.PaymentTypeId == 0 ? "" : Model.SettlementPayment.PaymentTypeId.ToString();
            }
            <input name="PaymentTypeId" id="PaymentTypeId" value="@paytype" class="easyui-combobox" style="width: 173px; height: 30px;" />
            <label>
                银行
            </label>
            <input name="Bank" id="Bank" class="easyui-combobox" value="@Model.SettlementPayment.Bank" style="width: 173px; height: 30px;" />
            <label>
                发票:
            </label>
            <input name="Invoice" id="Invoice" class="easyui-textbox" value="@Model.SettlementPayment.Invoice" style="width: 173px; height: 30px;" />
            <label>
                预收款余额:
            </label>
            <input id="PreAmount" name="PreAmount" value="@Model.SettlementPayment.PreAmount" class="easyui-numberbox" data-options="precision:'2',prompt:'预收款余金额'" style="width: 173px; height: 30px;" readonly="readonly" />
        </div>
        <div class="fitem1">
            <label>
                总金额:
            </label>
            <input id="Amount" name="Amount" value="@Model.SettlementPayment.Amount" class="easyui-numberbox" data-options="precision:'2',prompt:'总金额'" style="width: 173px; height: 30px;" readonly="readonly" />
            <label>
                实收金额:
            </label>
            <input id="ActualAmount" name="ActualAmount" value="@Model.SettlementPayment.ActualAmount" class="easyui-numberbox" data-options="precision:'2',prompt:'实收金额'" style="width: 173px; height: 30px;" readonly />
            @*<span id="zhekouspan">现金折扣:@Model.SettlementPayment.CashDiscount</span>*@

            <label>
                现金折扣:
            </label>
            <input id="zhekouspan" name="zhekouspan" value="@Model.SettlementPayment.CashDiscount" class="easyui-numberbox" data-options="precision:'2',prompt:'现金折扣'" style="width: 173px; height: 30px;" readonly="readonly" />
            <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addPayDetail()"></a>
        </div>
        <div class="fitem1">
            <label>
                备注:
            </label>
            <textarea rows="4" cols="4" style="width: 400px; height: 90px; vertical-align: top" name="Remark" id="Remark" autocomplete="off" placeholder="200字以内">@Model.SettlementPayment.Remark</textarea>
        </div>
        <div class="ftitle">费用明细</div>
        <div id="Wl">
            <div title="费用清单">
                <input id="DomNum" type="hidden" value="@(Model.Details.Count+1)" />
                @{
                    int i = 1;
                }
                <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addDom()">添加</a>
                <table class="gridtable" id="detailgird">
                    <thead>
                        <tr>
                            <th>日期</th>
                            <th>截止日期</th>
                            <th>天数</th>
                            <th>商品批号</th>
                            <th>商品名称</th>
                            <th>规格</th>
                            <th>类型</th>
                            <th>柜号</th>
                            <th>件重</th>
                            <th>件数</th>
                            <th>吨重</th>
                            <th>托盘数/面积</th>
                            <th>板数</th>
                            <th>冷藏单价</th>
                            <th>冷藏费用</th>
                            <th>处置费</th>
                            <th>装卸费</th>
                            <th>加班费</th>
                            <th>分检费</th>
                            <th>过磅费</th>
                            <th>配送费</th>
                            <th>其他费</th>
                            <th>小计</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.Details)
                        {
                            <tr id="@i">
                                <td>
                                    <span id="@("BeginTime")@i" class="inner_span">@item.BeginTime.ToString("yyyy-MM-dd")</span>
                                    <input type="hidden" id="@("DetailDomId")@i" value="@i" />
                                    <input type="hidden" id="@("DetailId")@i" value="@item.Id" />
                                    <input type="hidden" id="@("SettlementId")@i" value="@item.SettlementId" />
                                </td>
                                <td><span id="@("EndTime")@i" class="inner_span">@item.EndTime.ToString("yyyy-MM-dd")</span></td>
                                <td><span id="@("Days")@i" class="inner_span">@item.Days</span></td>
                                <td><span class="inner_span" id="@("GoodsNo")@i">@item.GoodsNo</span></td>
                                <td><span class="inner_span" id="@("GoodsName")@i">@item.GoodsName</span><input type="hidden" id="@("GoodsId")@i" value="@item.GoodsId" /></td>
                                <td><span class="inner_span" id="@("GoodsSpecName")@i">@item.GoodsSpecName</span><input type="hidden" id="@("GoodsSpecId")@i" value="@item.GoodsSpecId" /></td>
                                <td><span class="inner_span" id="@("CostType")@i">@item.CostType</span></td>
                                <td><span class="inner_span" id="@("ContainerNumber")@i">@item.ContainerNumber</span></td>
                                <td><span id="@("Weight")@i" class="inner_span">@item.Weight</span></td>
                                <td><span id="@("Number")@i" class="inner_span">@item.Number</span></td>
                                <td><span id="@("TonWeight")@i" class="inner_span">@item.TonWeight</span></td>
                                <td><span id="@("Area")@i" class="inner_span">@item.Area</span></td>
                                <td><span id="@("PlateNumber")@i" class="inner_span">@item.PlateNumber</span></td>
                                <td><span id="@("ColdUnitPrice")@i" class="inner_span">@item.ColdUnitPrice</span></td>
                                <td><span id="@("ColdCost")@i" class="inner_span">@item.ColdCost</span></td>
                                <td><span id="@("Chuzhi")@i" class="inner_span">@item.Chuzhi</span></td>
                                <td><span id="@("Zhuangxie")@i" class="inner_span">@item.Zhuangxie</span></td>
                                <td><span id="@("Jiaban")@i" class="inner_span">@item.Jiaban</span></td>
                                <td><span id="@("Fenjian")@i" class="inner_span">@item.Fenjian</span></td>
                                <td><span id="@("Guobang")@i" class="inner_span">@item.Guobang</span></td>
                                <td><span id="@("Peisong")@i" class="inner_span">@item.Peisong</span></td>
                                <td><span id="@("Qita")@i" class="inner_span">@item.Qita</span></td>
                                <td><span id="@("TotalAmount")@i" class="inner_span">@item.TotalAmount</span></td>
                            </tr>
                            i++;
                        }
                    </tbody>
                </table>
            </div>


            <div class="fitem1">
                @{
                    var modifyuser = Model.SettlementPayment.ModifyUserId == 0 ? Gx.Dal.Shared.UserContext.CurrentUser.EmpName : Model.SettlementPayment.ModifyUser;
                    var modifytime = Model.SettlementPayment.ModifyTime.ToString("yyyy-MM-dd") == "1911-01-01" ? "" : Model.SettlementPayment.ModifyTime.ToString("yyyy-MM-dd");
                }
                <label>
                    制单人:
                </label>
                <label>
                    @Model.SettlementPayment.CreateUser
                </label>

                <label>
                    制单日期:
                </label>
                <label>
                    @Model.SettlementPayment.CreateTime.ToString("yyyy-MM-dd")
                </label>
                <label>
                    修改人:
                </label>
                <label>
                    @modifyuser
                </label>
                <label>
                    修改日期:
                </label>
                <label>
                    @modifytime
                </label>
            </div>
        </div>
    </form>
    <div id="dlg" class="easyui-dialog" title="费用明细" data-options="iconCls:'icon-save'"
         closed="true" style="width: 1050px; height: 500px; padding: 10px 20px" buttons="#dlg-buttons" modal="true">
        <table id="dg" class="easyui-datagrid" style="width: 100%; height: 380px;"
               url="/Finance/GetLKSettlementPaymentDetailListByCustomer" toolbar="#tb" title="入库商品费用明细" rownumbers="true" pagination="false" fitcolumns="true" singleselect="false">
            <div id="tb" style="padding: 3px; height: auto;">
                <span>开始时间</span>
                <input class="easyui-datebox" name="BeginTime" id="BeginTime" style="width: 173px; height: 30px; ">
                <span>结束时间</span>
                <input class="easyui-datebox" name="EndTime" id="EndTime" style="width: 173px; height: 30px; ">
                <span>商品批号</span>
                <input id="GoodsNo" class="easyui-textbox " style="width: 173px; height: 30px;" />
                <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="doSearch()">查询</a>
            </div>
            <thead>
                <tr>
                    <th field="BeginTime" align="right" width="10%" formatter="formatter_BeginTime">
                        日期
                    </th>
                    <th field="EndTime" align="right" width="10%" formatter="formatter_EndTime">
                        截止日期
                    </th>
                    <th field="Days" align="right" width="10%">
                        天数
                    </th>
                    <th field="GoodsNo" align="right" width="10%">
                        商品批次
                    </th>
                    @*<th field="GoodsId" align="right" width="10%">
                    商品id
                </th>*@
                    <th field="GoodsName" align="right" width="10%">
                        商品名称
                    </th>
                    @*<th field="GoodsSpecId" align="right" width="10%">
                    规格
                </th>*@
                    <th field="GoodsSpecName" align="right" width="10%">
                        规格名称
                    </th>
                    <th field="CostType" align="right" width="10%">
                        类型
                    </th>
                    <th field="ContainerNumber" align="right" width="10%">
                        柜号
                    </th>
                    <th field="Weight" align="right" width="10%">
                        件重
                    </th>
                    <th field="Number" align="right" width="10%">
                        件数
                    </th>
                    <th field="TonWeight" align="right" width="10%">
                        吨重
                    </th>
                    <th field="Area" align="right" width="10%">
                        托盘数面积
                    </th>
                    <th field="PlateNumber" align="right" width="10%">
                        板数
                    </th>
                    <th field="ColdUnitPrice" align="right" width="10%">
                        冷藏单价
                    </th>
                    <th field="ColdCost" align="right" width="10%">
                        冷藏费用
                    </th>
                    <th field="Chuzhi" align="right" width="10%">
                        处置费
                    </th>
                    <th field="Zhuangxie" align="right" width="10%">
                        装卸费
                    </th>
                    <th field="Jiaban" align="right" width="10%">
                        加班费
                    </th>
                    <th field="Fenjian" align="right" width="10%">
                        分检费
                    </th>
                    <th field="Guobang" align="right" width="10%">
                        过磅费
                    </th>
                    <th field="Peisong" align="right" width="10%">
                        配送费
                    </th>
                    <th field="Qita" align="right" width="10%">
                        其他费
                    </th>
                    <th field="TotalAmount" align="right" width="10%">
                        总费用
                    </th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="selectEntryCostDetail()">选择</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
    </div>

    <div id="dlg2" class="easyui-dialog" title="付款明细" data-options="iconCls:'icon-save'"
         closed="true" style="width: 450px; height: 300px; padding: 10px 20px" buttons="#dlg-buttons" modal="true">
        <div class="fitem1">
            <label>
                现金或银行转账:
            </label>
            <input id="CashAndBank" name="ActualAmount" value="@Model.SettlementPayment.CashAndBank" class="easyui-numberbox" data-options="precision:'2',prompt:'现金或银行转账'" style="width: 173px; height: 30px;" />
        </div>
        <div class="fitem1">
            <label>
                预付款扣除:
            </label>
            <input id="PrePay" name="PrePay" value="@Model.SettlementPayment.PrePay" class="easyui-numberbox" data-options="precision:'2',prompt:'预付款扣除'" style="width: 173px; height: 30px;" />
        </div>
        <div class="fitem1">
            <label>
                现金折扣:
            </label>
            <input id="CashDiscount" name="CashDiscount" value="@Model.SettlementPayment.CashDiscount" class="easyui-numberbox" data-options="precision:'2',prompt:'现金折扣'" style="width: 173px; height: 30px;" />
        </div>
    </div>
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="savePayDetail()">确定</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg2').dialog('close')">取消</a>
    </div>
</div>











